package com.qf.ex;

import com.qf.util.Result;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
 *@Description:
 *@author:刘哥
 *@Date:17:38 2022/7/20
 */
@RestControllerAdvice
public class MyHandleException {
    @ExceptionHandler({
        CustomException.class
    })
    public Result handleCustomException(Exception e){
        e.printStackTrace();
        return Result.error(e.getMessage());
    }
    @ExceptionHandler({
            UnauthorizedException.class
    })
    public Result handleUnanuthorizedException(Exception e){
        e.printStackTrace();
        return new Result(401,"权限不足");
    }
    @ExceptionHandler({
            Exception.class
    })
    public Result handleOtherException(Exception e){
        e.printStackTrace();
        return Result.error("系统异常，请联系管理员");
    }
}
